#ifndef __TPUNB_H__
#define __TPUNB_H__
#ifdef __cplusplus
extern "C" {
#endif

#include "common.h"
#include "hydrology.h"

#define	QUEUE_INDEX_DEFAULT		0
#define	QUEUE_INDEX_VOICE		1
#define	QUEUE_INDEX_PICTURE		2
#define	QUEUE_INDEX_FILE		3

#define QUEUE_COUNT		6	//普通指令	语音 图片 文件

extern int fd_serial_tpunb;
extern Queue tpunbStack[QUEUE_COUNT];
extern pthread_mutex_t tpunbStackMutex;

extern void tpunbInit(void);
extern void tpunbDeinit(void);
extern void *tpunbTxLoop(void *arg);
extern void *tpunbRxLoop(void *arg);

extern char * get_tpunb_sn(void);

void enqueue_node(int queue_index, QueueNode *new_node);

int valid_gw_addr(int addr);
int valid_devnode_addr(int addr);
int valid_cellid(int cellid);
int valid_group(int group);

void tpunb_data_timeout_callback(void);

int netInfo_settings(int addr, int cellid, int group);

int tpunb_setNetInfo(unsigned short addr, unsigned char cellid, unsigned short group);

void get_netinfo_from_file(void);
void save_netinfo_to_file(unsigned short addr, unsigned char cellid, unsigned short group);

int get_gw_addr(void);
int get_gw_cellid(void);
int get_gw_group(void);

int is_tpunb_ok();

void gw_netInfo_settings_rsp(void);
void devNode_netInfo_settings_rsp(char *devNode_sn, unsigned short addr, unsigned char cellid);

int get_tpunb_relay(bool reboot_tpunb);
void set_getrelay_opr(bool reboot_tpunb);

int is_dequeue_start(void);

#ifdef __cplusplus
}
#endif
#endif
